package p270jp.pxv.android.advertisement.presentation.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import com.five_corp.p083ad.C1921s;
import com.five_corp.p083ad.FiveAdConfig;
import com.five_corp.p083ad.FiveAdCustomLayout;
import com.five_corp.p083ad.FiveAdFormat;
import com.five_corp.p083ad.FiveAdInterface;
import java.util.EnumSet;
import java.util.Objects;
import p064c6.Preconditions;
import p155fe.FiveServiceInitializer;
import p189gn.AbstractC3435a;
import p216hn.Lambda;
import p216hn.Reflection;
import p312le.FiveAdListenerImpl;
import p325m0.MutabilityOwnership;
import p350mp.Timber;
import p376no.Koin;
import p404oo.AbstractC5475a;
import p579vo.Qualifier;
import p603wm.AbstractC6949c;

/* compiled from: LineDisplayView.kt */
/* renamed from: jp.pxv.android.advertisement.presentation.view.LineDisplayView */
/* loaded from: classes2.dex */
public final class LineDisplayView extends FrameLayout implements AbstractC5475a {

    /* renamed from: a */
    public final AbstractC6949c f18789a = Preconditions.m9802P(1, new C4157b(this, null, null));

    /* renamed from: b */
    public FiveAdCustomLayout f18790b;

    /* compiled from: LineDisplayView.kt */
    /* renamed from: jp.pxv.android.advertisement.presentation.view.LineDisplayView$a */
    /* loaded from: classes2.dex */
    public static final class C4156a extends FiveAdListenerImpl {
        public C4156a() {
            LineDisplayView.this = r1;
        }

        @Override // com.five_corp.p083ad.FiveAdListener
        /* renamed from: c */
        public void mo4666c(FiveAdInterface fiveAdInterface) {
            MutabilityOwnership.m3745m(fiveAdInterface, "f");
            Timber.C4879b bVar = Timber.f23100a;
            bVar.mo3520i("fivead onFiveAdLoad", new Object[0]);
            fiveAdInterface.mo9564a(false);
            LineDisplayView lineDisplayView = LineDisplayView.this;
            FiveAdCustomLayout fiveAdCustomLayout = lineDisplayView.f18790b;
            if (fiveAdCustomLayout != null) {
                if (fiveAdCustomLayout.getParent() == null) {
                    lineDisplayView.addView(fiveAdCustomLayout);
                } else {
                    bVar.mo3514p(new IllegalStateException("fivead fiveAdView parent exists"));
                }
            }
        }
    }

    /* compiled from: KoinComponent.kt */
    /* renamed from: jp.pxv.android.advertisement.presentation.view.LineDisplayView$b */
    /* loaded from: classes2.dex */
    public static final class C4157b extends Lambda implements AbstractC3435a<FiveServiceInitializer> {

        /* renamed from: a */
        public final /* synthetic */ AbstractC5475a f18792a;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4157b(AbstractC5475a aVar, Qualifier aVar2, AbstractC3435a aVar3) {
            super(0);
            this.f18792a = aVar;
        }

        /* JADX WARN: Type inference failed for: r0v4, types: [fe.e, java.lang.Object] */
        @Override // p189gn.AbstractC3435a
        public final FiveServiceInitializer invoke() {
            return this.f18792a.getKoin().f24118a.m920a().m621a(Reflection.m5499a(FiveServiceInitializer.class), null, null);
        }
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public LineDisplayView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        MutabilityOwnership.m3745m(context, "context");
        MutabilityOwnership.m3745m(attributeSet, "attributeSet");
    }

    private final FiveServiceInitializer getFiveInitializer() {
        return (FiveServiceInitializer) this.f18789a.getValue();
    }

    @Override // p404oo.AbstractC5475a
    public Koin getKoin() {
        return AbstractC5475a.C5476a.m3211a(this);
    }

    public final void setup(String str) {
        boolean z;
        MutabilityOwnership.m3745m(str, "slotId");
        FiveServiceInitializer fiveInitializer = getFiveInitializer();
        Context context = getContext();
        MutabilityOwnership.m3746l(context, "context");
        Objects.requireNonNull(fiveInitializer);
        String str2 = fiveInitializer.f14498a.isDebug() ? "15100" : "85450362";
        try {
            synchronized (C1921s.f8084c) {
                z = C1921s.f8085d != null;
            }
            if (!z) {
                FiveAdConfig fiveAdConfig = new FiveAdConfig(str2);
                fiveAdConfig.f5930b = EnumSet.of(FiveAdFormat.CUSTOM_LAYOUT);
                fiveAdConfig.f5931c = fiveInitializer.f14498a.isDebug();
                try {
                    C1921s.m9142c(context, fiveAdConfig);
                } finally {
                }
            }
            View view = this.f18790b;
            if (view != null) {
                removeView(view);
            }
            FiveAdCustomLayout fiveAdCustomLayout = new FiveAdCustomLayout(getContext(), str, getWidth());
            fiveAdCustomLayout.setListener(new C4156a());
            this.f18790b = fiveAdCustomLayout;
            FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-2, -2);
            layoutParams.gravity = 17;
            setLayoutParams(layoutParams);
        } finally {
        }
    }
}
